<template>
  <div class="article">
    <div class="header">
      <van-nav-bar
        title="写字的事"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />
    </div>
    <!--文章内容  -->
    <div class="article-con">
      <div class="article-wrap" v-for="item in res.articles" :key="item.id">
        <img :src="item.originalUrl" alt="" />
        <h3>{{ item.title }}</h3>
        <p>{{ item.intro }}</p>
        <h4>
          {{ new Date(item.publishTime).getFullYear() }}-{{
            new Date(item.publishTime).getMonth() + 1
          }}-{{ new Date(item.publishTime).getDate() }}
        </h4>
      </div>
    </div>
  </div>
</template>

<script setup>
import { getCurrentInstance, reactive } from "vue";
const { $axios } = getCurrentInstance().appContext.config.globalProperties;

const onClickLeft = () => history.back();

let res = reactive({
  articles: {},
});
$axios("/apixt/core/api/articles?page=1&pageSize=10&type=2").then((data) => {
  res.articles = data.data;
  console.log(res.articles);
});
</script>

<style lang="less">
.article {
  height: 100vh;
  overflow-y: scroll;
  &::-webkit-scrollbar {
    display: none;
  }
  .article-con {
    padding: 20px;
    .article-wrap {
      img {
        height: 192px;
      }
      h3 {
        font-weight: normal;
        color: #333;
        font-style: 18px;
        margin: 15px 0;
      }
      p {
        font-size: 14px;
        line-height: 25px;
        color: #999;

        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
      h4 {
        margin: 10px 0 20px 0;
      }
    }
  }
}
</style>
